<?=modules::run('home/top');?>

<body>
<?php
	include_once('function/func.php');
	$user=$this->session->userdata('ProfileInfo');
	if(!$user){
		header('Location: '.PATH_URL);
	}
	
?>
<div id="wrapper">
	<header>
		<?=modules::run('home/head');?>
	</header>
	
	<nav id="nav">
		<?=modules::run('home/menu')?>
	</nav>
	
	<div class="content">
		<h1>Đơn hàng</h1>

        
        <div id="show_checkout" style="margin-top: 20px;float: left;display: inline">
            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                <tr>
                    <th></th>
                    <th width="340px">Sản phẩm</th>
                    <th width="135px">Giá</th>
                    <th width="70px">Số lượng</th>
                    <th width="160px">Tộng cộng</th>
                    <?php if($status[0]->status==0 && $status[0]->idProfile==$user['id']):?>
                    <th width="30px"></th>
                    <?php endif;?>
                </tr>
                <?php
					$prcie_all='';
					$price='';
					foreach($result as $row){
						$product=$this->productsModel->getOne($row->idProduct);
						foreach($product as $r){
							if($r->price_new !=0 && $r->promotion !=0){
								$price=$row->qty * $r->price_new;
							}else{
								$price=$row->qty * $r->price_old;
							}
							
							$prcie_all +=$price;
				?>
                <tr>
                    <td><img src="<?=PATH_URL.IMAGES_PRODUCTS.$r->image?>" width="100" height="100" /></td>
                    <td><a href="<?=PATH_URL.'san-pham/chi-tiet/'.$r->id.''?>"><?=$r->title;?></a></td>
                    <td align="center" class="price">
                    	<?php if($r->price_new != 0 && $r->promotion != 0){?>
                        <?=number_format($r->price_new,0,',','.');?> vnđ
                        <?php }else{?>
                       	<?=number_format($r->price_old,0,',','.');?> vnđ
                        <?php }?>
                       </td>
                    <td align="center"><?=$row->qty;?></td>
                    <td align="center" class="price"><?=number_format($price,0,',','.');?> vnđ</td>
                    <?php if($status[0]->status==0 && $status[0]->idProfile==$user['id']):?>
                    <td><img style="cursor: pointer" width="16" height="16" src="<?=PATH_URL?>static/images/btn_trash.gif" onClick="delCartOne(<?=$r->id?>,<?=$id?>,<?=$user['id']?>);" title="Xóa"></td>
                    <?php endif;?>
                </tr>
                <?php }}?>
                <tr>
                    <td align="right" colspan="4"><b style="color:#7E8DF8;font-size: 20px">Tổng giá tiền</b></td>
                    <td align="center" class="price"><?=number_format($prcie_all,0,',','.');?> vnđ</td>
                    <?php if($status[0]->status==0 && $status[0]->idProfile==$user['id']):?>
                    <td></td>
                    <?php endif;?>
                </tr>
            </table>
            
            <dir class="button" style="margin-top: 20px;"><a href="<?=PATH_URL.'thong-tin-don-hang/'.$user['id']?>">Quay lại</a></dir>
            <?php if($status[0]->status==0 && $status[0]->idProfile==$user['id']):?>
            <dir class="button" style="margin-top: 20px; float: right" onclick="delCartDetail(<?=$id?>,<?=$user['id']?>); return false">Xóa đơn hàng</dir>
            <?php endif;?>
        </div>
	</div><!--end content-->
	
	<footer>
		<?=modules::run('home/footer');?>
	</footer>
</div><!--end wrapper-->
</body>
</html>
